<?php
class Application_Form_AddBook extends Zend_Form
{
	public function init()
	{
		$this->setName('book');
		$this->setMethod('post');
		
		$this->setDecorators(array(array('viewScript', array('viewScript'=>'Form_Add.phtml'))));
		
		$title = new Zend_Form_Element_Text('title');
		$title->setRequired(true)
		->addFilter('StripTags')
		->addValidator('NotEmpty')
		->removeDecorator('HtmlTag')
		->removeDecorator('Label');
		
		$author = new Zend_Form_Element_Text('author');
		$author->setRequired(true)
		->addFilter('StripTags')
		->addValidator('NotEmpty')
		->removeDecorator('HtmlTag')
		->removeDecorator('Label');
		
		$price = new Zend_Form_Element_Text('price');
		$price->addFilter('Int')
		->setRequired(true)
		->addValidator('Between',true,array(1,200))
		->setValue('1')
		->removeDecorator('HtmlTag')
		->removeDecorator('Label');
		
		$description = new Zend_Form_Element_Textarea('description');
		$description->setAttribs(array('rows'=>'5', 'cols'=>30))
		->setRequired(true)
		->addValidator('NotEmpty')
		->addFilter('StripTags')
		->removeDecorator('HtmlTag')
		->removeDecorator('Label');
		
		
		$image = new Zend_Form_Element_File('image');
		$image->setDestination(APPLICATION_PATH.'/../public/upload')
		->setRequired(true)
		->addValidator('ExcludeExtension', false, array('jpg'=>true,'png'=>true,'gif'=>true,'jpeg'=>true,'bmp'=>true))
		->removeDecorator('HtmlTag')
		->removeDecorator('Label');
		
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setAttrib('id', 'submitbutton')
		->setLabel('Add new book')
		->removeDecorator('DtDdWrapper');
		//gán vào $this
		$this->addElements(array($title, $author, $price, $image, $description, $submit));
	}

}
?>